package com.rushb.rushbproduct.controller;

import com.rushb.rushbproduct.entity.Product;
import com.rushb.rushbproduct.entity.dto.DeleteProductDto;
import com.rushb.rushbproduct.entity.dto.InsertProductDto;
import com.rushb.rushbproduct.entity.dto.SelectProductDto;
import com.rushb.rushbproduct.entity.dto.UpdateProductDto;
import com.rushb.rushbproduct.result.Result;
import com.rushb.rushbproduct.service.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * rush-b</n>
 * ProductController
 * </p>
 *
 * @author zhaolun.li
 * @since 2020/11/30 17:00
 */
@RequestMapping("/prod")
@RestController
@Slf4j
public class ProductController {

    @Autowired
    ProductService productService;

    @RequestMapping("/selectAllProduct")
    public Result<List<Product>> selectAllProduct(){
        return productService.selectAllProduct();
    }

    @RequestMapping("/selectProduct")
    public Result<List<Product>> selectProduct(@RequestBody SelectProductDto product){
        return productService.selectProduct(product);
    }

    @RequestMapping("/insertProduct")
    public Result<String> insertProduct(@RequestBody InsertProductDto product){
        return productService.insertProduct(product);
    }

    @RequestMapping("/updateProduct")
    public Result<String> updateProduct(@RequestBody UpdateProductDto product){
        return productService.updateProduct(product);
    }

    @RequestMapping("/deleteProduct")
    public Result<String> deleteProduct(@RequestBody DeleteProductDto product){
        return productService.deleteProduct(product);
    }
}
